package stru1.day11;

/**
 * 104. 二叉树的最大深度
 */
public class Solution2 {
    public static void main(String[] args) {
        System.out.println(maxDepth(new TreeNode(3, new TreeNode(9),
                new TreeNode(20, new TreeNode(15, null, null), new TreeNode(7, null, null)))));
    }

    /**
     * 递归
     */
    public static int maxDepth(TreeNode root) {
        return root == null ? 0 : Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }
}
